//第六个文件:thread.c
//启动线程(创建线程,并且工作线程的工作是收发数据)
#include "thread.h"

void * work_thread(void *arg)
{
    int c=(int)arg;

    while(1)
    {   
        char buff[128]={0};
        int n=recv(c,buff,127,0);
        if(n<=0)
        {
            break;
        }

        printf("buff=%s\n",buff);
        send(c,"ok",2,0);
    }   

    close(c);
    printf("client close\n");
}
void start_thread(int c)
{
    pthread_t id; 
    pthread_create(&id,NULL,work_thread,(void *)c);
}
